package com.simple.mipc.utils;

import java.lang.reflect.Field;

public class FieldUtil {

    public static <T> void setValue(Object instance, Field field, T value) {
        boolean accessible = field.isAccessible();
        try {
            field.setAccessible(true);
            field.set(instance, value);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        } finally {
            field.setAccessible(accessible);
        }
    }
}
